package everyday;

import java.util.HashSet;

/**
 * @author le
 */
public class Day07
{
    public static void main(String[] args)
    {
        int[] nums = {0,0,1,1,1,1,2,3,3};
        int end = removeDuplicates(nums);
        for(int i = 0;i < end;i++){
            System.out.println(nums[i]);
        }
    }

    public static int removeDuplicates(int[] nums) {
        if (nums.length == 0){
            return 0;
        }
        if (nums.length == 1){
            return 1;
        }
        int cmp = nums[0];
        int index = 0;
        int flag = 0;
        for (int i = 1;i < nums.length;i++){
            if (cmp == nums[i]){
                flag++;
                if (flag >= 2){
                    continue;
                }else {
                    index++;
                    nums[index] = nums[i];
                }
            }else{
                index++;
                nums[index] = nums[i];
                cmp = nums[index];
                flag = 0;
            }
        }
        return index+1;
    }
}
